/*
 * (C) Copyright 2012, by Tim Xie.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.superapk.diamond.test;

import com.superapk.diamond.R;
import com.superapk.diamond.widget.NewsView;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

/**
 * 消息提示组件，类似微博在底部菜单栏显示“News”
 * 
 * @author     Tim Xie [tim.xie2008@gmail.com]
 * @date 2013-2-21
 * 
 */

public class NewsViewActivity extends Activity {

	private ImageView mEditIV;
	
	private NewsView mNewsViewEdit;

	private ImageView mShareIV;
	
	private NewsView mNewsViewShare;

	private ImageView mDeleteIV;
	
	private NewsView mNewsViewDelete;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.activity_newsview);

		mEditIV = (ImageView) findViewById(R.id.edit);
		mShareIV = (ImageView) findViewById(R.id.share);
		mDeleteIV = (ImageView) findViewById(R.id.delete);
		
		mEditIV.setOnClickListener(mOnClickListener);
		mShareIV.setOnClickListener(mOnClickListener);
		mDeleteIV.setOnClickListener(mOnClickListener);

		mNewsViewEdit = new NewsView(this, mEditIV);
		mNewsViewEdit.setText("77");
		mNewsViewEdit.show();

		mNewsViewShare = new NewsView(this, mShareIV);
		mNewsViewShare.setText("1");
		mNewsViewShare.show();

		mNewsViewDelete = new NewsView(this, mDeleteIV);
		mNewsViewDelete.setText("News");
		mNewsViewDelete.show();
	}
	
	private OnClickListener mOnClickListener = new OnClickListener(){

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch(v.getId()){
				case R.id.edit:
					if(mNewsViewEdit.isShown()){
						mNewsViewEdit.hide();
					}else{
						mNewsViewEdit.show();
					}
					break;
				case R.id.share:
					if(mNewsViewShare.isShown()){
						mNewsViewShare.hide();
					}else{
						mNewsViewShare.show();
					}
					break;
				case R.id.delete:
					if(mNewsViewDelete.isShown()){
						mNewsViewDelete.hide();
					}else{
						mNewsViewDelete.show();
					}
					break;
			}
		}
		
	};

}
